package com.newlink.building.userinfo.mvp

import com.newlink.building.common_base.base.BasePresenter
import com.newlink.building.common_base.ext.ss
import com.newlink.building.common_base.http.exception.Base_ErrorStatus
import com.newlink.building.common_base.utils.logDebug
import com.newlink.building.userinfo.mvp.contract.Module_UserInfo_AccountInformationBindPhoneContract
import com.newlink.building.userinfo.mvp.model.Module_UserInfo_AccountInformationBindPhoneModel

/**
 * @author wangyang
 * @date 2022/10/29
 * @description 我的——账户信息——绑定手机号页面的Presenter
 */
class Module_UserInfo_AccountInformationBindPhonePresenter :
    BasePresenter<Module_UserInfo_AccountInformationBindPhoneContract.Model, Module_UserInfo_AccountInformationBindPhoneContract.View>(),
    Module_UserInfo_AccountInformationBindPhoneContract.Presenter {

    override fun createModel(): Module_UserInfo_AccountInformationBindPhoneContract.Model {
        return Module_UserInfo_AccountInformationBindPhoneModel()
    }

    override fun getBindCode(token: String, code: String, phone: String) {
        mModel?.getBindCode(token, code, phone)?.ss(mModel, mView) {
            logDebug<Module_UserInfo_AccountInformationBindPhonePresenter>("getVerifyCode response ->  ${it?.data}")
            if (it?.code == Base_ErrorStatus.SUCCESS) {
                if (it.data.result == 0) {
                    mView?.getVerifyCodeFailed(it.data.reason)
                } else {
                    mView?.getVerifyCodeSuccess()
                }
            } else {
                mView?.getVerifyCodeFailed("")
            }

        }
    }


}